/*=============================================================================
// File Name: 
// Author: 
// Date: 
// Version: 

=============================================================================*/

#ifndef _BM1422AGMV_H_
#define _BM1422AGMV_H_


#ifdef __cplusplus
extern "C" {
#endif

#include "drv_i2c.h"


#define BM1422AGMV_DEVICE_ADDRESS_0E   (0x0E)    // 7bit Address    ADDR = L
#define BM1422AGMV_DEVICE_ADDRESS_0F   (0x0F)    // 7bit Address    ADDR = H
#define BM1422AGMV_WIA_VAL             (0x41)

#define BM1422AGMV_WIA                 (0x0F)   //ID = 0X41
#define BM1422AGMV_DATAX               (0x10)   //XYZ: 0X10-0X15
#define BM1422AGMV_STA1                (0x18)   //STATUS: 0X00 = NG,0X40= OK
#define BM1422AGMV_CNTL1               (0x1B)
#define BM1422AGMV_CNTL2               (0x1C)
#define BM1422AGMV_CNTL3               (0x1D)
#define BM1422AGMV_AVE_A               (0x40)   //Average Time:000:4times, 001:1times, 010:2times, 011:8times, 100:16times
#define BM1422AGMV_CNTL4               (0x5C)

#define BM1422AGMV_TEMP                (0x60)   //Temperature value L_H

#define BM1422AGMV_OFF_X               (0x6C)   //
#define BM1422AGMV_OFF_Y               (0x72)
#define BM1422AGMV_OFF_Z               (0x78)

#define BM1422AGMV_FINEOUTPUT_XYZ      (0x90)   //

#define BM1422AGMV_GAINPARA_XYZ        (0x9C)   //



#define BM1422AGMV_STA1_RD_DRDY        (1 << 6)     //0 = NG,1= OK

#define BM1422AGMV_CNTL1_FS1           (1 << 1)     //0=CONTINU MODE,1=SINGLE MODE
#define BM1422AGMV_CNTL1_ODR_10Hz      (0 << 3)     //00=10Hz,01=100Hz,10=20Hz,11=1KHz
#define BM1422AGMV_CNTL1_RST_LV        (1 << 5)     //0=Reset Release,1=Reset
#define BM1422AGMV_CNTL1_OUT_BIT       (1 << 6)     //0=12BIT,1=14BIT
#define BM1422AGMV_CNTL1_PC1           (1 << 7)     //0=POWERDOWN,1=ACTIVE

#define BM1422AGMV_CNTL2_DRP           (1 << 2)     //DRDY :0=LOW ACTIVE,1=HIGH ACTIVE
#define BM1422AGMV_CNTL2_DREN          (1 << 3)     //DRDYENABLE:0=DISABLE,1=ENABLE

#define BM1422AGMV_CNTL3_FORCE         (1 << 6)     //AD start measurement trigger at continuous OR single.Set 1: Start measurement

#define BM1422AGMV_AVE_A_AVE4          (0 << 2)     //000:4times

#define BM1422AGMV_CNTL1_VAL           (BM1422AGMV_CNTL1_FS1 | BM1422AGMV_CNTL1_OUT_BIT | BM1422AGMV_CNTL1_PC1)
#define BM1422AGMV_CNTL2_VAL           (BM1422AGMV_CNTL2_DREN)
#define BM1422AGMV_CNTL3_VAL           (BM1422AGMV_CNTL3_FORCE)
#define BM1422AGMV_CNTL4_VAL           (0x0000)
#define BM1422AGMV_AVE_A_VAL           (BM1422AGMV_AVE_A_AVE4)

#define BM1422AGMV_14BIT_SENS          (24)
#define BM1422AGMV_12BIT_SENS          (6)



extern  uint8_t BM1422AGMV_Init(void);
extern  void BM1422AGMV_get_rawdata(uint8_t *buff);
extern  void BM1422AGMV_get_val(float *data);


void BM1422AGMV_get_temperature(uint8_t *buff);
void BM1422AGMV_get_offxyz(uint8_t *buff);
void BM1422AGMV_set_offxyz(uint8_t *buff);

void BM1422AGMV_get_fineoutput_xyz(uint8_t *buff);
void BM1422AGMV_get_gainpara_xyz(uint8_t *buff);



extern  void BM1422AGMV_power_down(void);


#ifdef __cplusplus
}
#endif

#endif // _BM1422AGMV_H_


